﻿using Kernel.Dapper.Factory;
using static Dapper.SimpleCRUD;

namespace WebAPI.Configure;

public static class DapperConnectionExtensions
{
    public static void RegisterDapperConnection(this IServiceCollection services, IConfiguration configuration)
    {
        //连接sqlserver
        services.AddDapper(DapperConst.DB_SQLSERVER, m =>
        {
            m.ConnectionString = configuration.GetSection("DBConnction:SqlServerConnection").Value;
            m.DbType = Dialect.SQLServer;
        });
        //连接Oracle
        services.AddDapper(DapperConst.DB_ORACLE, m =>
        {
            m.ConnectionString = configuration.GetSection("DBConnction:OracleConnection").Value;
            m.DbType = Dialect.Oracle;
        });
        //连接MySQL
        services.AddDapper(DapperConst.DB_MYSQL, m =>
        {
            m.ConnectionString = configuration.GetSection("DBConnction:MySQLConnection").Value;
            m.DbType = Dialect.MySQL;
            m.UseMultitenant = false;
        });
    }

}
